package model;

import java.util.LinkedList;

public class Word {

	private String value;
	private final LinkedList<Occurence> oList;
	private String lang;
	
	
	public static Word create(final String value, final Occurence o, final String lang){
		final Word word = new Word();
		word.value = value;
		word.oList.add(o);
		word.lang = lang;
		return word;
	}
	
	private Word(){
		this.setValue("");
		this.oList = new LinkedList<Occurence>();
		this.setLang("");
	}

	public void setValue(final String value) {
		this.value = value;
	}

	public String getValue() {
		return value;
	}

	public LinkedList<Occurence> getO() {
		return oList;
	}
	
	public void addOccurence(final Occurence o){
		this.oList.add(o);
	}
	
	public void addOccurence(final LinkedList<Occurence> oList){
		this.oList.addAll(oList);
	}
	
	public void normalize(){
		
		final NormalizeEnglish normalizeEnglish = new NormalizeEnglish();
		final NormalizeGerman normalizeGerman = new NormalizeGerman();
		
		if(this.isEnglish()){
			normalizeEnglish.normalize(this);
		}
		
		if(this.isGerman()){
			normalizeGerman.normalize(this);
		}
		
	}

	public void setLang(final String lang) {
		this.lang = lang;
	}

	private String getLang(){
		return this.lang;
	}
	
	public Boolean isGerman(){
		return this.getLang() == "german";
	}
	
	public Boolean isEnglish(){
		return this.getLang() == "english";
	}
	
}
